home *** CD-ROM | disk | FTP | other *** search
/ BCI NET / BCI NET Dec 94.iso / archives / programming / utilities / trap.lha / TrapII.DOC < prev    next >
Encoding:
Text File  |  1992-02-07  |  25.1 KB  |  550 lines

  1.  
  2.           DOC file for TrapIIv1.11b © 1992 Nicolas Dade.
  3. Permission is hereby granted for non-commercial distribution and duplication.
  4.  last changed: Feb 4th, 1992
  5.  
  6. TrapII is of no use of you are not programming in a compiled language. It is
  7. of greatest use to an assembly language programmer.
  8.  
  9. Some of the things TrapII does fall in the category of hacks, so no
  10. guarantee is stated or implied by the author concerning the suitability of
  11. this program for any purpose what so ever, and the author can take no
  12. responsibility as to any damages, disappointments, etc... that follow the
  13. (attempted) use of this program. However, on the bright side, this program
  14. has worked as described on the author's A1000 under WB1.3.
  15.  
  16. TrapII tries to help you (the programmer) by giving you much more
  17. information when your program (hereafter also referred to as the target)
  18. causes the 680x0 to enter exception handling code than does the normal
  19. system default. That is, now when the target tries to read/write a word/long
  20. from/to an odd address, instead of getting a requestor "system
  21. requestor/software error/task held/finish all disk activity/cancel to
  22. debug/reset", followed by a GURU which tells you it was you program that had
  23. the odd address, you get a (SMART refresh) window from TrapII...
  24.  
  25.   ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
  26.  
  27. New in 1.3: (1.1 & 1.2 were just bug fixes)
  28. 1) Safer task restarting: version 1.2 could make a mess of the target's
  29.    signals if there were interrupts and other tasks talking to the target.
  30.    Because of this new code not only is Forbid() used (correctly this time),
  31.    but for about 20 clock cycles (68000), Disable() is too.
  32. 2) target_wait code changed to support Disable().
  33.  
  34. New in 1.4:
  35. 1) Got rid of the screen moving thing, and changed the screen to front so
  36.    that it calls ScreenToFront(wd's screen) instead WBenchToFront()
  37.  
  38. New in 1.6: (1.5 was bug fix)
  39. 1) Changed window gadgets so that [Off] is gone (use rmb), [OK/Ignore] is
  40.    gone (use close gadget), and a new one, [Trace], is given. With trace
  41.    you can step through your code instruction by instruction, until you
  42.    are tired of this, and just hit [Restart].
  43. 2) Safe handling of USP. Now your task can use a7 for anything it desires-
  44.    it does not have to point to a stack. TrapII allocates a mini-stack
  45.    for the target to use when the target is being shutdown and restarted.
  46. 3) Got rid of the ScreenToFront() when the TrapII window opens altogether.
  47.  
  48. New in 1.7
  49. 1) Added [Next] gadget & function.
  50. 2) Window is no longer closed after [Restart], [Trace] or [Next] is pressed.
  51.    This saves a lot of time on a clogged wb screen, and reminds you that
  52.    the task is off doing something.
  53. 3) Changed the offset/segment finding code so that if the target is started
  54.    from WB the offset/segment can still be found, and so that if the segment
  55.    list seems too long (i.e. corrupted), we are not in a perpetual loop
  56.  
  57. New in 1.8
  58. 1) Added keyboard equivalents for the gadgets:
  59.    [Next] = N
  60.    [Trace] = T
  61.    [Restart] = R
  62. 2) Fixed bug in TrapII which was generating address errors (which I traced by
  63.    having two TrapIIs running one on top of the other, and using the second
  64.    to trace through the first!)
  65.  
  66. New in 1.9
  67. 1) Added keyboard equivalents for close and sleep
  68.    Close/Ok/Ignore = O
  69.    Sleep = Z
  70. 2) Added support for [Next]ing through loops which end in BCC
  71. 3) Window deiconifies when a key is pressed (well, most keys)
  72.  
  73. New in 1.10
  74. 1) Fixed window closing code in hope of avoiding crashes.
  75.  
  76. New in 1.11
  77. 1) Found that bug!, and fixed it for good. (the one where if you click twice
  78.    on anything really quickly then you get an addr error).
  79. 2) Changed wd closing code to use arp.library's CloseWindowSafely()
  80.  
  81. New in 1.11b
  82. 1) Bug fix of bug in version distributed to ab20 (sorry).
  83.  
  84.   ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
  85.  
  86. The contents of the window TrapII opens for each trap are best explained
  87. by looking at an example:
  88. To see this example in real life, open a CLI, cd to the directory TrapII
  89. is in, and type the following two lines:
  90.  run <nil: >nil: TrapII
  91.  run demo
  92. (the source for demo is as follows:
  93.     TRAP    #$0 ; cause a TRAP #$0 trap
  94.     TRAP    #$F ; cause a TRAP #$F trap
  95.     MOVEQ.L #9,d0
  96.     MOVEQ.L #0,d1
  97. label ; this loop is used to demo [Trace]
  98.     ADDQ.L  #1,d1
  99.     DBF.W   d0,label
  100.     TRAP    #$1 ; cause a TRAP #$1 trap after the loop
  101.     BSR.S   subroutine ; used to demo [Next]
  102.     MOVE.W  D0,label+1 ; cause an address error trap
  103.     CLR.L   D0 ; actually, this instruction is never reached
  104.     RTS
  105.  
  106. subroutine
  107.     MOVE.W  #$FFFF,D2
  108.     MOVE.W  #$004F,D3
  109. sub_loop
  110.     DBF.W   D2,sub_loop
  111.     DBF.W   D3,sub_loop
  112.     RTS
  113. )
  114. (If you like, the demo can also be run from workbench. Double-click TrapII,
  115. then double-click demo.)
  116.  
  117. You should see, in the workbench screen, a window looking like:
  118.  
  119.           +­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+
  120.        line 1 |D nnnnnnnn  A nnnnnnnn FUNC -,-,----|
  121.         2 |1 nnnnnnnn  1 nnnnnnnn       ----    |
  122.         3 |2 nnnnnnnn  2 nnnnnnnn ADDR --------|
  123.         4 |3 nnnnnnnn  3 nnnnnnnn  /--------,--|
  124.         5 |4 nnnnnnnn  4 nnnnnnnn INST ----    |
  125.         6 |5 nnnnnnnn  5 nnnnnnnn (SP) nnnnnnnn|
  126.         7 |6 nnnnnnnn  6 nnnnnnnn  4() nnnnnnnn|
  127.         8 |7 nnnnnnnn SP nnnnnnnn  8() nnnnnnnn|
  128.         9 | SR nnnnnnnnnnnnnnnn    C() nnnnnnnn|
  129.        10 |    T-S--III---XNZVC   TRAP #$0       |
  130.        11 | PC nnnnnnnn/00000002,00  +­­­­­­­­­+
  131.        12 |PROC demo         |RemTask()|
  132.        13 |  nnnnnnnn   +­­­­­­­+­­­­+­+­­­­­­­+
  133.        14 |hh:mm:ss     |Restart| Next | Trace |
  134.           +­­­­­­­­­­­­­+­­­­­­­+­­­­­­+­­­­­­­+
  135.  
  136. (n,h,m and s represent values that may be different each time demo is run)
  137. (n represents a hex number, hh,mm,ss represent decimal)
  138. the information is grouped in fields, as shown below:
  139.  
  140.           +­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+
  141.        line 1 |       |         |           |
  142.         2 | Data Regs | Addr Regs| Address Data|
  143.         3 |       |         |           |
  144.         4 |       |         |       AD       |
  145.         5 |    DR      |    AR    |_____________|
  146.         6 |       |         |           |
  147.         7 |       |         | Top of Stack|
  148.         8 |___________|__________|       SK       |
  149.         9 |              |_____________|
  150.        10 | SR & PC          |___Trap__TP__|
  151.        11 |________________________|       |
  152.        12 | Task TK   _____________| Gadgets   |
  153.        13 |__________|           GG       |
  154.        14 | Time TM |           (or status) |
  155.           +­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+
  156.  
  157.  ** DR **
  158. The data registers as they were then the trap occurred. The contents are
  159. given as hexadecimal unsigned longs.
  160. (When I write trap, I mean when the 68000 entered exception processing
  161. code. When I write TRAP, I mean the TRAP #n instruction.)
  162.  
  163.  ** AR **
  164. The address registers as they were then the trap occurred. The contents are
  165. given as unsigned longs. SP (A7), is the user stack pointer (USP), regardless
  166. of what the 68000's mode was when the trap occured.
  167.  
  168.  ** SR **
  169. The status register (SR) the 680x0 pushed on the stack when the trap occur-
  170. red, in binary. Below (line 10) is the meaning of the bits of the SR for a
  171. 68000.
  172.  
  173.  ** PC **
  174. The PC the 680x0 pushed on the stack when the trap occurred, given two
  175. ways.
  176. The first is the absolute value of the PC. This points to the instruction
  177. following the instruction that caused the trap, except in the case of bus
  178. and address errors, in which case it may point to somewhere in the instruc-
  179. tion that caused the trap. The PC points to the next instruction in memory,
  180. not the next it would have executed. Thus if the offending instruction was
  181. a JMP (to an odd address), for example, the PC points to just beyond the
  182. JMP in memory, not the address to jump to. This representation of the PC
  183. is useful if you are using a disassembler/debugger to look in memory.
  184. If you are using a disassembler, get is started and look at the address
  185. PC. You should see the code for demo, with the PC pointing to the second
  186. TRAP instruction (the TRAP #$f).
  187. The second representation of the PC (after the "/") is the offset from the
  188. start of the hunk the PC points in, followed by the hex number of that
  189. hunk (0 = first hunk). So 00000002,00 indicates that the PC points to an
  190. address 2 bytes beyond the start of the first hunk. A look at the source
  191. for demo (above) will show the PC points to the instruction following the
  192. first TRAP #0. This value is usefull for looking at the listing the assembler
  193. created, and for some disassemblers  and debuggers which look at the segment
  194. lists of loaded commands.
  195. (The hunk number must be less than 255, or no hunk number will be displayed)
  196.  
  197.  ** SK **
  198. These are the top four long words on the user stack. These are correct
  199. even if the USP is odd. Line 6 shows the topmost data. These are only useful
  200. in conjunction with a disassembler (if the trap occurred in a subroutine,
  201. you can see from where that routine was called).
  202.  
  203.  ** TP **
  204. This is a text description of the trap that occurred. Currently it says a
  205. TRAP #$0 instruction was reached. It can also say:
  206. Bus Error, Address Error, Illegal Instruction, Zero Divide, CHK Instruction,
  207. TRAPV Instruction, Privilege Violation, Trace, Line 1010 Emulation, Line
  208. 1111 Emulation, Next (used with [Next]), and, if the trap type is none of
  209. the above, trap nnnnnnnn, where nnnnnnnn is the number of the trap that
  210. occurred.
  211.  
  212.  ** TK **
  213. This field tries to identify what task/process caused the trap. First
  214. (line 12) are the letters "PROC" or "TASK", stating whether the target is
  215. a task or a process. In this case, demo was started by a CLI, and so is a
  216. process.
  217. To the right of this are up to 19 characters of text. These are the "best"
  218. name for the target TrapII could find:
  219. If the target is a task, then this is the name of the task, as pointed to
  220. by LN_NAME(target task structure).
  221. If the target is a process, then
  222.  If the target has a CLI, then
  223.   If the CLI has a non null command name (pointed to by cli_CommandName),
  224.    then this is that command name.
  225. else this is the task name, just as if the target were a task.
  226. Below (line 13) gives the address of the target's task/process structure.
  227.  
  228.  ** TM **
  229. This is the system time at which the trap occurred. This is not very exact,
  230. but it will allow you to look at multiple TrapII windows, and determine
  231. which is the "freshest." The time is the ONLY numerical value that is not
  232. in hexadecimal in the TrapII windows.
  233.  
  234.  ** GG **
  235.  
  236.  [Restart] (or the R key)
  237. This sets the target running where it stopped with the trace bit cleared.
  238. This only works if a set of conditions are all met:
  239.  [RemTask()] has not been used.
  240.  The trap was due to a TRAP #n instruction or a Trace (or a Next, which is
  241.   really a TRAP #$n).
  242.  The target has some signal bits allocated that are not used by its exception
  243.   code. (as of now, signal bits 0-15 are guarenteed to fall in this category,
  244.   so don't worry about this)
  245.  And the target has entered a wait state. (the target has proceeded out of
  246.   my trap handler, to some shutdown code.)
  247. This function allows TrapII to be used to halt/look at your program at
  248. selected places by putting a TRAP instruction where you want to halt and
  249. look at your program, or restart your program to full speed execution after
  250. you have stopped it.
  251. Once the target has been restarted, the gadgets are replaced by the text
  252. "Target Restarted" until the target enters its exception code again (say,
  253. from a TRAP #$n which you placed in your code, or [Next]'s TRAP #$0 at the
  254. exit of the subroutine which you [Next]ed into).
  255.  
  256.  [Trace] (or the T key)
  257. This sets the target running where it stopped with the trace bit set. Same
  258. conditions as for [Restart] apply.
  259. Actually first looks at the next instruction. If it is a TRAP, TRAPV, and if
  260. the execution of the instruction would generate an exception, then the
  261. instruction is just executed, with the trace bit off.
  262. If the instruction is a CHK or a DIV, no tracing is tried, because the
  263. potential double trap due to CHK being out of bounds or a DIV by 0 and the
  264. Trace sends the TrapII trap handler into a guru! Therefore a "Next" is always
  265. used when you try to [Trace] these instructions (this is done automatically
  266. for you, you just press [Trace])
  267.  
  268.  [Next] (or the N key)
  269. This only works on a few instructions. It puts a TRAP #n just beyond the
  270. next instruction, then sets the target running where it stopped with the
  271. trace bit cleared. It only works on BCC, BSR, DBCC and JSR instructions,
  272. and uses the address of the instruction following the BCC, BSR, DBCC or
  273. JSR, and on the BRA.s, BRA and JMP instruction, where it uses the address
  274. on the stack (this is an easy speed up when a subroutine ends with the
  275. calling of another subroutine) (if you try to [Trace] a CHK or DIV, the
  276. [Next] function is used, but you cannot explicitly [Next] a CHK or DIV).
  277. The idea of this is to allow subroutines (or system calls) that you know
  278. work/don't want to trace through to execute a full speed, but still stop
  279. the target when it returns back to the subroutine level at which you were.
  280. Once the target stops because of the TRAP #n, the word I changed in order
  281. to put a TRAP #n is restored, and the task is stopped for a Next trap.
  282. [Next], of course, does not work if you are in ROM, since it must alter the
  283. next instruction.
  284. NOTE: If you close the window of a task which is [Nexting] then the code
  285. is restored; you have essentially done a [Restart].
  286. WARNING: you may NOT nest [Next] calls. Do not do a [Next] into a subroutine
  287. which contains a TRAP, and then [Next] inside that subroutine to a second
  288. one, or the first [Next] will be canceled (its Trap #n removed).
  289. WARNING: if the subroutines called are such that the target never gets back
  290. to the instruction following the BCC, BSR, DBCC or JSR, or the address on
  291. the stack at a BRA or JMP then by doing a [Next] you have essentially done a
  292. [Restart], since the target will never get back to the TRAP #n which would
  293. stop it. You will not confuse TrapII by doing this, but remember that the
  294. instruction (or first word thereof) which was changed to a TRAP #n is not
  295. restored until THAT TRAP #n is reached. While a [Next] is being done, the
  296. window is not closed, but the gadgets are replaced by "-Doing [Next]-" to
  297. tell you that the target is executing.
  298. NOTE: since [Next] changes your code, if several tasks are running on the
  299. same code, all of them will react to the change; the target will find a
  300. Next exception, the others will find a TRAP #$0.
  301. NOTE: since [Next] reacts differently for a BRA and a BCC, you cannot [Next]
  302. through a subroutine which you get to by a BCC. (Maybe in the next version
  303. I will split the Next function into two: Next to next instruction and Next
  304. to addr on stack)
  305.  
  306.  [RemTask()]
  307. This does a RemTask(target). It is provided in order to unclutter your
  308. system task list of "old" invocations of your program OR to stop any excep-
  309. tion code from executing. If the target uses exception code, then you have
  310. better use this if you don't want your exception code to execute; TrapII
  311. does nothing to halt exception processing.
  312. After this function is used, [Restart] and [Trace] can no longer be used.
  313. This function does not close the TrapII window.
  314. This function does not free any memory used by the target.
  315.  
  316. In addition:
  317.  
  318.  The Close Window Gadget (or the O key)
  319. This closes the TrapII window, and leaves the target as it is. If the
  320. target is not executing ([Restart], [Trace] or [Next]), and [RemTask()] has
  321. not been used, then the target is in a wait state, waiting for nothing
  322. (Wait(0)).
  323. If, during a [Restart], [Trace] or [Next] you close the window, then if some
  324. of you code has been changed in order to do a [Next], that code is restored
  325. in the process of closing the window. This means that if you close the
  326. window during a [Next] then you could just as well have done a [Restart],
  327. since the instruction which would have stopped the target at the exit of
  328. the subroutine is now gone.
  329.  
  330.  The Right Mouse Button (or the Z key)
  331. This shrinks the window to a small bar. To reopen the window, make the bar
  332. window active, then click the right mouse button.
  333.  
  334.  
  335. Back to the demo:
  336. Since our trap is a TRAP #0 instruction, we can use [Restart] to continue.
  337. Press it now. The task "demo" is restarted, executes the next instruction,
  338. TRAP #$F, enters exception handling code, which culminates in TrapII
  339. updating its window for the target with this new information.
  340. This is another TRAP #n instruction trap, so nothing much is new (except
  341. the PC has incremented by 2).
  342. Now lets try to trace through the loop. Press [Trace]. The task "demo"
  343. is restarted, but because the trace bit is set, one instruction executes
  344. and then the CPU internally generates trace exception, which causes it
  345. to enter exception handling code, and eventually TrapII undates the
  346. window to inform you of this. Keep pressing [Trace] and see the PC run
  347. through the loop, d0 count down and d1 count up.
  348. When you are tired of this, press [Restart]. Now the task "demo" is
  349. restarted with the trace bit cleared, so now it runs full speed until it
  350. finds the TRAP #$1 at the end of the loop. Since the next instruction
  351. is a BSR.S, we can use [Next] to let the subroutine execute at full speed
  352. but yet gain control of the target back once the subroutine is finished.
  353. Press [Next], and the subroutine counts down, returns, and then causes
  354. a Next trap. [Next] is a way to "trace" through subroutines that you are
  355. not interrested in actually [Trace]ing through (like system calls or
  356. subroutines that you know (ha!) have no bugs).
  357. Press [Restart] to send the target doing again until it causes an address
  358. error as it tries to load from the odd address label+1.
  359. Now the AD field is filled in.
  360.  
  361.  ** AD **
  362. This shows the information the 68000 dumps in its stack frame when a bus or
  363. address error occurs. It should look like:
  364.  
  365.             ­­­­­­­­­­­­­­+
  366.         line 1     FUNC W,I,UsDt|
  367.              2          33c1    |
  368.              3     ADDR nnnnnnnn|
  369.              4      /00000009,00|
  370.              5     INST 33c0    |
  371.  
  372. FUNC shows the specific information concerning the memory access that
  373. caused the bus/address error.
  374. The first letter gives the direction of the access, W = write, R = read.
  375. The second letter gives what state the 68000 was in when the error occured
  376. I = executing an instruction, N = not executing an instruction (responding
  377. to an interrupt, another trap, etc...)
  378. The third field represents the function code that was on pins FC0,FC1 and
  379. FC2 of the 68000. It can be:
  380. UsDt...user data ; accessing source or destination
  381. UsPg...user program ; reading an instruction
  382. SpDt...supervisor data
  383. SpPg...supervisor program
  384. IAck...interrupt acknowledge
  385. ????...something else TrapII doesn't know how to interpret.
  386. Below (line 2) is the whole hex value of the function code the 68000 dumped
  387. on the stack. This is only useful if TrapII's interpretation of this value
  388. is not enough.
  389.  
  390. ADDR shows the address that caused the bus/address error. It is given
  391. first as an absolute address (line 3), then as an offset and hunk number
  392. (line 4), like the PC.
  393.  
  394. INST shows the hex value of the instruction the 68000 was executing when the
  395. trap occurred.
  396.  
  397.   ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
  398.  
  399. How TrapII works:
  400. (limited overview, skips many details, but lets you know what happens to
  401. the target)
  402.  
  403. TrapII adds to the AddTask() call a bit of code that compares the new
  404. task's trap code (TC_TRAPCODE) with both the system default (TaskTrapCode*)
  405. and the TC_TRAPCODE of TrapII itself. This is because TC_TRAPCODE of a
  406. task started by a CLI or workbench is not the system default (I don't know
  407. why). If the new task is using either, then TC_TRAPCODE is changed to
  408. point to TrapII's trap handler.**
  409.  
  410. Then TrapII waits for a signal from its trap handler.
  411.  
  412. When a new task causes a trap to occur (and has not installed its own trap
  413. handler), TrapII's handler is executed.
  414. The handler dumps the 68000's registers, the 68000's stack frame in a
  415. buffer, signals TrapII, and invents a new stack frame that clears T and S
  416. bits of the SR, and changes the PC to point to TrapII's target_wait code,
  417. evens the USP to TrapII's ministack, and rte's.
  418.  
  419. The target now executes the target_wait code, which consists of just Wait(0).
  420.  
  421. TrapII is reawakened, opens a new window and all that, and goes back to
  422. sleep.
  423.  
  424. When [Restart], [Trace] or [Next] is hit, then the target's wait stack frame
  425. is altered to point to TrapII's restart_target code, and the target is
  426. reawakened.
  427.  
  428. The target now executes the restart_target code, which restores the regis-
  429. ters to what was displayed in the TrapII window, and control proceeds to
  430. where the target left off.
  431.  
  432. [Next] is done by computing the length of the BSR[.S] or JSR, or getting
  433. the "return address" off the top of the stack, and putting a TRAP #0 at that
  434. next instruction. Then, whenever that task traps, if it trapped because
  435. of that TRAP #0, then it is cosidered a Next trap, the word altered to put
  436. the TRAP #0 is restored, and the PC is backed up 2 bytes so that the next
  437. instruction is that which was originally there. (If you have a disassembler
  438. you can see this: [Next] into a loop that contains a TRAP #$n. Once the
  439. target has hit the TRAP #$n, look at the instruction following the BSR or
  440. JSR you used to enter the subroutine. It will be the TRAP #0 TrapII put
  441. there. Once you [Restart] the target, and it exits the subroutine, TrapII's
  442. TRAP #0 is reached, and the code is restored to what is was before, which
  443. your disassembler will show you too if you look at that address again.)
  444. Of course, this is in fact a form of that great crasher of harvard
  445. architecture machines, self-modifying code, but at the top of this doc
  446. file I did say that TrapII did some hacks, and this is one of them
  447. (just keep this in mind if you are using a cache).
  448.  
  449. * TrapII does NOT change TaskTrapCode(execbase), because I do not see any
  450. advantage in doing this; I found no task that used it.
  451.  
  452. ** This way, if a task is going to use its own trap handler, either by
  453. later changing the value TC_TRAPCODE, or by having the task's launcher set
  454. it, TrapII will not get in the way.
  455. This also means any task started before TrapII was run will still be using
  456. the system's trap handler, which is why `run' was required to run the demo.
  457.  
  458.   ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
  459.  
  460. Limitations, Problems & Additional Notes:
  461.  
  462. Because of the way the trap handler and TrapII interact, there is a short
  463. time period between the time the trap occurred and the window is opened
  464. during which a second trap, will not be reported by TrapII. However, the
  465. offending task will be put into a perpetual wait state (Wait(0)).
  466. This time period lasts from when the trap occurs to a bit before the window
  467. is opened. This includes two AllocMem() calls.
  468.  
  469. It is not such a good idea to have TrapII running at a very low priority;
  470. In order to display its windows, TrapII does have to run. Priority 0 is
  471. good enough in most cases, but if you have customized the priorities of
  472. various tasks on your system, then you may need to run TrapII at a different
  473. priority.
  474.  
  475. TrapII will only effect tasks started (AddTask()) after it was run.
  476. This means that if you open a CLI, type "run trapii", then "your program",
  477. your program will NOT be using TrapII's trap handler, because "your program"
  478. is running using the CLI's task structure, and that was added to the system
  479. when the CLI was opened--before TrapII was run. However, if you typed "run
  480. your program", "your program" would use TrapII's trap handler, because run
  481. started a new task for "your program", and that task was started after
  482. TrapII was run.
  483.  
  484.   ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
  485.  
  486. Use:
  487.  
  488. Because targets started different ways seem to have different trap handling
  489. code, in order to be sure TrapII will work, TrapII must be started in the
  490. same manner the target will be started. For this reason, TrapII can be
  491. started from both a CLI or Workbench. It is true that sometimes, on some
  492. setups, with some programs running or not running, that a TrapII started
  493. one way can trap programs started another. However this behavior cannot be
  494. guaranteed; if it works on your system, use it if you like, but remember
  495. if, all of a sudden, TrapII isn't intercepting your program's errors any
  496. more, you will have to start TrapII the way I recommend.
  497.  
  498. NOTE: the author has used this program to debug AmigaDOS device handlers
  499. under 1.3 and a beta 2.0 by starting it running with
  500.  run TrapII
  501. from a CLI. I guess the DOS's startup-a-handler routine uses the same trap
  502. handler as run. However C= makes no promises that this will work forever.
  503.  
  504. WB:
  505. just double-click on icon
  506.  
  507. CLI:
  508. Here it seems that whether a task is started by:
  509.  target_name
  510. or with a run, it doesn't change the trap handler so you can start TrapII
  511. with:
  512.  run TrapII
  513. or, better, with:
  514.  run <nil: >nil: TrapII
  515. If you are using arun (arp's run), then TrapII can be started with arun:
  516.  arun >nil: TrapII noio
  517. because, it seems, arun uses the same trap handler than run (ArpRelease1.3)
  518.  
  519. If TrapII must be started at a non zero priority (let's use 3), then you
  520. can use either:
  521.  ChangeTaskPri 3
  522.  TrapII
  523. or:
  524.  ChangeTaskPri 3
  525.  Run <nil: <nil: TrapII
  526. or:
  527.  ARun >nil: TrapII pri 3 noio
  528.  
  529. Now clever users may well be thinking doing this in their startup-sequence.
  530. This may work on your machine, but it does not on the author's. It seems
  531. the startup-sequence's trap handling code is not the same as later CLI's!
  532. However it might work with your setup, so don't let this dissuade you from
  533. trying.
  534.  
  535. However, it does seem that a task started from workbench has the same trap
  536. handler as one started from a CLI (it seems everyone is using CreateProc()).
  537.  
  538.   ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
  539.  
  540. I can be reached through:
  541.  
  542.  Nicolas Dade
  543.  405 W Delaware
  544.  Urbana, IL, 61801    (USA)
  545.  
  546. or maybe nsd20463@uxa.cso.uiuc.edu
  547.  
  548.   ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
  549.  
  550.